const char *datadir;
const char *imagedir;
const char *userdatadir;
- StFocusManager *focus_manager;
-
+ GFile *userdatadir_path;
GFile *runtime_state_path;
+ StFocusManager *focus_manager;
+
guint work_count;
GSList *leisure_closures;
guint leisure_function_id;
/* Ensure config dir exists for later use */
global->userdatadir = g_build_filename (g_get_user_data_dir (), "gnome-shell", NULL);
g_mkdir_with_parents (global->userdatadir, 0700);
+ global->userdatadir_path = g_file_new_for_path (global->userdatadir);
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
byteorder_string = "LE";
the_object = NULL;
+ g_clear_object (&global->userdatadir_path);
g_clear_object (&global->runtime_state_path);
G_OBJECT_CLASS(shell_global_parent_class)->finalize (object);
return global->session_mode;
}
-static GFile *
-get_runtime_state_path (ShellGlobal *global,
- const char *property_name)
-{
- return g_file_get_child (global->runtime_state_path, property_name);
-}
-
-/**
- * shell_global_set_runtime_state:
- * @global: a #ShellGlobal
- * @property_name: Name of the property
- * @variant: (allow-none): A #GVariant, or %NULL to unset
- *
- * Change the value of serialized runtime state.
- */
-void
-shell_global_set_runtime_state (ShellGlobal *global,
- const char *property_name,
- GVariant *variant)
+static void
+save_variant (GFile *dir,
+ const char *property_name,
+ GVariant *variant)
{
- GFile *path;
-
- path = get_runtime_state_path (global, property_name);
+ GFile *path = g_file_get_child (dir, property_name);
if (variant == NULL || g_variant_get_data (variant) == NULL)
(void) g_file_delete (path, NULL, NULL);
g_object_unref (path);
}
-/**
- * shell_global_get_runtime_state:
- * @global: a #ShellGlobal
- * @property_type: Expected data type
- * @property_name: Name of the property
- *
- * The shell maintains "runtime" state which does not persist across
- * logout or reboot.
- *
- * Returns: (transfer floating): The value of a serialized property, or %NULL if none stored
- */
-GVariant *
-shell_global_get_runtime_state (ShellGlobal *global,
- const char *property_type,
- const char *property_name)
+static GVariant *
+load_variant (GFile *dir,
+ const char *property_type,
+ const char *property_name)
{
GVariant *res = NULL;
GMappedFile *mfile;
- GFile *path;
+ GFile *path = g_file_get_child (dir, property_name);
char *pathstr;
GError *local_error = NULL;
- path = get_runtime_state_path (global, property_name);
pathstr = g_file_get_path (path);
mfile = g_mapped_file_new (pathstr, FALSE, &local_error);
if (!mfile)
return res;
}
+
+/**
+ * shell_global_set_runtime_state:
+ * @global: a #ShellGlobal
+ * @property_name: Name of the property
+ * @variant: (allow-none): A #GVariant, or %NULL to unset
+ *
+ * Change the value of serialized runtime state.
+ */
+void
+shell_global_set_runtime_state (ShellGlobal *global,
+ const char *property_name,
+ GVariant *variant)
+{
+ save_variant (global->runtime_state_path, property_name, variant);
+}
+
+/**
+ * shell_global_get_runtime_state:
+ * @global: a #ShellGlobal
+ * @property_type: Expected data type
+ * @property_name: Name of the property
+ *
+ * The shell maintains "runtime" state which does not persist across
+ * logout or reboot.
+ *
+ * Returns: (transfer floating): The value of a serialized property, or %NULL if none stored
+ */
+GVariant *
+shell_global_get_runtime_state (ShellGlobal *global,
+ const char *property_type,
+ const char *property_name)
+{
+ return load_variant (global->runtime_state_path, property_type, property_name);
+}
+
+/**
+ * shell_global_set_persistent_state:
+ * @global: a #ShellGlobal
+ * @property_name: Name of the property
+ * @variant: (allow-none): A #GVariant, or %NULL to unset
+ *
+ * Change the value of serialized persistent state.
+ */
+void
+shell_global_set_persistent_state (ShellGlobal *global,
+ const char *property_name,
+ GVariant *variant)
+{
+ save_variant (global->userdatadir_path, property_name, variant);
+}
+
+/**
+ * shell_global_get_persistent_state:
+ * @global: a #ShellGlobal
+ * @property_type: Expected data type
+ * @property_name: Name of the property
+ *
+ * The shell maintains "persistent" state which will persist after
+ * logout or reboot.
+ *
+ * Returns: (transfer none): The value of a serialized property, or %NULL if none stored
+ */
+GVariant *
+shell_global_get_persistent_state (ShellGlobal *global,
+ const char *property_type,
+ const char *property_name)
+{
+ return load_variant (global->userdatadir_path, property_type, property_name);
+}